/*
 * @Description: 星币账单
 * @Author: iamsmiling
 * @Date: 2021-06-13 13:59:13
 * @LastEditTime: 2021-06-13 14:35:23
 */
import 'package:credit_business_circle/R/R.dart';
import 'package:credit_business_circle/components/button/roatet_button.dart';
import 'package:credit_business_circle/domain/remote/bill/kpi_bill_entity.dart';
import 'package:flutter/material.dart';

class KpiBillFragment extends StatelessWidget {
  final List<KpiBillEntity> bills;
  const KpiBillFragment({Key? key, this.bills = const []}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Column(
        children: [
          Container(
            margin: EdgeInsets.symmetric(
                horizontal: R.dimen.dp12, vertical: R.dimen.dp18),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Container(
                  padding: EdgeInsets.symmetric(
                      horizontal: R.dimen.dp16, vertical: R.dimen.dp8),
                  decoration: BoxDecoration(
                      color: R.color.ffffffff,
                      borderRadius: BorderRadius.circular(R.dimen.sp20)),
                  child: RotateButton(
                    onPressed: () => Future.value(),
                    label: Container(
                      margin: EdgeInsets.only(right: R.dimen.dp6),
                      child: Text(
                        "2020-03",
                        style: TextStyle(
                            fontSize: R.dimen.sp12, color: R.color.ff333333),
                      ),
                    ),
                  ),
                ),
                Text(
                  "获取星币：660星币",
                  style: TextStyle(
                      fontSize: R.dimen.sp13,
                      color: R.color.ff333333,
                      fontWeight: FontWeight.w600),
                )
              ],
            ),
          ),
          Container(
            padding: EdgeInsets.symmetric(horizontal: R.dimen.dp12),
            color: R.color.ffffffff,
            child: ListView.separated(
                shrinkWrap: true,
                padding: EdgeInsets.zero,
                itemBuilder: (BuildContext context, int i) {
                  KpiBillEntity b = bills[i];
                  return Container(
                    padding: EdgeInsets.symmetric(vertical: R.dimen.dp20),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        // Container(
                        //   width: R.dimen.dp4,
                        //   height: R.dimen.dp4,
                        //   decoration: BoxDecoration(
                        //       color: R.color.ff1d9c76,
                        //       borderRadius:
                        //           BorderRadius.circular(R.dimen.dp2 / 2)),
                        // ),
                        Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            Row(
                              children: [
                                Text("●    ",
                                    style: TextStyle(
                                        fontSize: R.dimen.sp6,
                                        // fontWeight: FontWeight.bold,
                                        color: R.color.ff1d9c76)),
                                Text.rich(TextSpan(
                                    text: "一级会员充值",
                                    style: TextStyle(
                                        fontSize: R.dimen.sp13,
                                        color: R.color.ff333333),
                                    children: [
                                      TextSpan(
                                          text: "100",
                                          style: TextStyle(
                                              fontSize: R.dimen.sp15,
                                              color: R.color.ff333333,
                                              fontWeight: FontWeight.w500))
                                    ]))
                              ],
                            ),
                            Container(
                              margin: EdgeInsets.only(top: R.dimen.dp10),
                              child: Row(
                                children: [
                                  Text("●    ",
                                      style: TextStyle(
                                          fontSize: R.dimen.sp6,
                                          // fontWeight: FontWeight.bold,
                                          color: R.color.transparent)),
                                  Text(
                                    b.date,
                                    style: TextStyle(
                                        color: R.color.ff888888,
                                        fontSize: R.dimen.sp11),
                                  )
                                ],
                              ),
                            ),
                          ],
                        ),
                        Text(
                          b.description,
                          style: TextStyle(
                              fontSize: R.dimen.sp12, color: R.color.ff222222),
                        ),

                        b.expense
                            ? Text(
                                "+${b.count}星币",
                                style: TextStyle(
                                    fontSize: R.dimen.sp13,
                                    color: R.color.fffb5c06,
                                    fontWeight: FontWeight.w500),
                              )
                            : Text(
                                "-${b.count}星币",
                                style: TextStyle(
                                    fontSize: R.dimen.sp13,
                                    color: R.color.ff111111,
                                    fontWeight: FontWeight.w500),
                              )
                      ],
                    ),
                  );
                },
                separatorBuilder: (BuildContext context, int i) {
                  return Divider(
                    height: 1,
                  );
                },
                itemCount: bills.length),
          )
        ],
      ),
    );
  }
}
